<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<jsp:include page="../jqgrid.jsp"></jsp:include>

</head>
<script type="text/javascript">
function queryCarPosition() {
	var url = "queryCarPositionAll.action";
	var types = "";
	$.ajax({
		type : "POST",
		url : url,
		dataType : "json",
		async : false,
		success : function(data) {
			$.each(data, function(i, item) {
				types += item["id"] + ":" + item["position"] + ";";
			});
		}
	});
	return types.substring(0, types.lastIndexOf(";"));
} 
	$(document).ready(function() {
		jQuery("#stopCarlist").jqGrid({
			url : 'queryStopCar.action',
			autowidth : true,
			datatype : "json",
			colNames : [ 'id','停车位ID','停车位','房间号','车主名字','登记时间','车型'],
			colModel : [ {
				name : 'id',
				index : 'id',
				width : 55,
				editable : false,
				hidden:true
			}, {
				name : 'positionId',
				index : 'positionId',
				width : 50,
				hidden:true,
				editable : true,
				edittype:"select",
				editrules:{
					required:true,
					edithidden:true
				},
				editoptions:{
					value:queryCarPosition
				}
			},{
				name : 'position',
				index : 'position',
				align : "center",
				width : 20,
				editable : false,
				editrules:{
					required:false,
				},
				searchoptions :{
					sopt:['cn','nc']
				}
			},{
				name : 'houseCode',
				index : 'houseCode',
				align : "center",
				width : 20,
				editable : true,
				editrules:{
					required:true,
				},
				searchoptions :{
					sopt:['cn','nc']
				}
			},{
				name : 'name',
				index : 'name',
				align : "center",
				width : 20,
				editable : true,
				editrules:{
					required:true,
				},
				searchoptions :{
					sopt:['cn','nc']
				}
			},{
				name : 'regesterTime',
				index : 'regesterTime',
				width : 50,
				editable : true,
				formatter : "date",
				align : "center",
				editrules:{
					required:true,
					date:true
				},
				formatoptions : {
					"newformat" : "Y-m-d"
				},
				editoptions : {
					size : 10,
					maxlengh : 10,
					dataInit : function(element) {
						$(element).datepicker({
							dateFormat : 'yy-mm-dd'
						});
					}
				},
				searchoptions:{dataInit:datePick,sopt:['le','ge']}

			},{
				name : 'type',
				index : 'type',
				width : 20,
				align : "center",
				editable : true,
				editrules:{
					required:true,
				},
				searchoptions :{
					sopt:['cn','nc']
				}

			}],
			rowNum : 10,
			rowList : [ 10, 20, 30 ],
			pager : '#stopCargridPager',
			sortname : 'id',
			viewrecords : true,
			jsonReader : {
				repeatitems : false
			},
			sortorder : "desc",
			caption : "停车信息列表",
			editurl:"editStopCar.action"
		});
		jQuery("#stopCarlist").jqGrid('navGrid', '#stopCargridPager', {
			edit : true,
			add : true,
			del : true
		}, {}, {}, {},{multipleSearch:true});
	});
	datePick = function(elem)
	{
	   jQuery(elem).datepicker();
	}
</script>
<body>
	<div align="center">
		<table id="stopCarlist"></table>
		<div id="stopCargridPager"></div>
	</div>
</body>
</html>